package cn.icanci.test.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author icanci
 * @date Created in 2021/03/06 15:39
 * @version 1.0
 */
@Aspect
@Order(2)
@Component
public class HiServiceAspect {
    @Pointcut("execution(* cn.icanci.test.service.impl.HiServiceImpl.*(..))")
    public void plugin() {

    }

    @Before("plugin()")
    public void before(JoinPoint joinPoint) {
        System.out.println("开始调用：" + joinPoint);
    }

    @After("plugin()")
    public void after(JoinPoint joinPoint) {
        System.out.println("调用完成：" + joinPoint);
    }

    @AfterReturning(pointcut = "plugin()", returning = "returnValue")
    public void afterReturning(JoinPoint joinPoint, Object returnValue) {
        System.out.println("无论是否是空还是有值都返回 " + joinPoint + "，返回值：" + returnValue);
    }

}
